﻿#ifndef SPELLCHECKER_H
#define SPELLCHECKER_H

#include <QDialog>
#include <QHash>
#include <QStringList>
#include <QMessageBox>
#include <QFileDialog>
#include <QProgressDialog>

#include "ortho.h"
#include "orthoconfig.h"
#include "textedit.h"
#include "widget.h"


namespace Ui {
class SpellChecker;
}

class SpellChecker : public QDialog
{
	Q_OBJECT

private:
	Ui::SpellChecker *ui;
	OrthoConfig* m_config;
	TextEdit* m_textEdit;
	QProgressDialog* m_progress;

	int m_badIndex;
	void loadLanguages ();
	QString currentText () { return m_textEdit->toPlainText (); }
	void setCurrentText (QString txt) { m_textEdit->setPlainText (txt); }
	QString m_saveText;

	Ortho* m_ortho;

	void sendOptionsToOrtho ();
	void replaceInCurrentText (const QString &bad, const QString &good);

	bool userAgrees (const QString& text);

private slots:
	void onReplaceAllClicked ();
	void onUnknownComboIndexChanged (QString newWord);
	void onLanguagesCurrentIndexChange (QString lang);
	void onIgnoreClicked ();
	void onOptionsDisplay();
	void onAddToPersonalDicClicked ();
	void onRemoveWordFromTextClicked ();
	void onReplaceAlwaysClicked ();
	void onClearPersonalDic ();
	void onClearTranslateDic ();
	void onRunAutoSpellingClicked ();
	void onCancelAutoSpellingClicked ();
	void onMessageFromOrtho (QString msg);
	void onPersonalDicChange ();
	void onTranslateDicChange ();

	void updateDialog();

	void on_personalDicList_currentTextChanged(const QString &currentText);

	void on_removeLineFromPersonalDic_clicked();

	void on_translateDicList_currentTextChanged(const QString &currentText);

	void on_removeLineFromTranslateDic_clicked();

	void on_mergePersonalDic_clicked();

	void on_analyzeAgain_clicked();


	void on_save_clicked();

	void on_quit_clicked();

	void on_copyToClipboard_clicked();

	void on_fontSize_currentIndexChanged(const QString &arg1);

public:
	explicit SpellChecker(Widget *parent = 0);
	~SpellChecker();

	void initFontSizeMenu ();
public slots:
	void onSuggestListTextChanged(QString newWord);
	int run (const QString& text);
	void onTabsCurrentChanged (const int index);
	QString text () { return m_textEdit->toPlainText (); }
	void onFontSizeChanged(const QString &size);

signals:

};

#endif // SPELLCHECKER_H
